
<div class="section" id="sitemaplist">

	<div class="section-title">Phân quyên</div>
    
    <div class="section-content padding1">
    
    	<form name="frm" id="frm" action="<?php echo $action?>" method="post" enctype="multipart/form-data">
        
        	<div class="button right">
            	<a class="button save" onclick="save()">Lưu</a>
                <a class="button cancel" href="?route=deliman/loainhanvien">Bỏ qua</a>   
     	        <input type="hidden" name="loainhanvienid" value="<?php echo $item['loainhanvienid']?>">
            </div>
            <div class="clearer">^&nbsp;</div>
        	<div id="error" class="error" style="display:none"></div>
        	<div>   
                
                 <p>
                    <label>Tên loại nhân viên:</label>
                    <?php echo $item['tenloainhanvien']?> <input type="checkbox" onClick="$('.phanquyen').attr('checked', this.checked)"> Chọn hết
                </p>
                
                <table class="table-border">
                	<?php foreach($chucnangs as $chucnang){ ?>
                    <tr>
                    	<td><?php echo $chucnang['tenchucnang']?></td>
                        <td>
                        	<div class="left">
                        	<input type="checkbox" name="all" class="phanquyen" onClick="$('.<?php echo $chucnang['chucnangid']?>').attr('checked', this.checked)"> Toàn quyền
                            </div>
                             <div class="left">
                            <input type="checkbox" class="<?php echo $chucnang['chucnangid']?> phanquyen" name="phanquyen[<?php echo $chucnang['machucnang']?>]" value="<?php echo $chucnang['machucnang']?>" <?php echo in_array($chucnang['machucnang'],$quyens)?'checked':''?>> Xem
                            </div>
                        	<?php foreach($chucnang['hanhdongs'] as $hanhdong){ ?>
                            <div class="cell-phanquyen left">
                            	<input type="checkbox" class="<?php echo $chucnang['chucnangid']?> phanquyen" name="phanquyen[<?php echo $hanhdong['hanhdongid']?>]" value="<?php echo $hanhdong['mahanhdong']?>" <?php echo in_array($hanhdong['mahanhdong'],$quyens)?'checked':''?>> <?php echo $hanhdong['tenhanhdong']?>
                            </div>
                            <?php } ?>
                            <div class="clearer">^&nbsp;</div>
                        </td>
                    </tr>
                    <?php } ?>
                </table>
            </div>
            
        </form>
    
    </div>
    
</div>

<script language="javascript">

<!--thực hiện chức năng save dữ liệu-->
function save()
{
	$.blockUI({ message: "<h1>Please wait...</h1>" }); 
	
	$.post("?route=deliman/loainhanvien/savePhanQuyen", $("#frm").serialize(),
		function(data){
			if(data == "true")
			{
				window.location = "?route=deliman/loainhanvien";
			}
			else
			{
			
				$('#error').html(data).show('slow');
				$.unblockUI();
				
			}
			
		}
	);
}
</script>
